package machinery.decorator;

import machinery.Machinery;
import machinery.state.MachineryState;
import java.util.Map;

/**
 * 装饰器模式：农机装饰器基类
 */
public abstract class MachineryDecorator extends Machinery {
    protected Machinery decoratedMachinery;
    
    public MachineryDecorator(Machinery decoratedMachinery) {
        super(decoratedMachinery.getName(), decoratedMachinery.getType());
        this.decoratedMachinery = decoratedMachinery;
        // 继承被装饰对象的状态
        this.state = decoratedMachinery.getState();
    }
    
    @Override
    public void update(Map<String, Object> environmentData) {
        // 先让被装饰的农机执行更新
        decoratedMachinery.update(environmentData);
        // 装饰器额外的更新逻辑
        additionalUpdate(environmentData);
    }
    
    // 装饰器提供的附加更新逻辑
    protected abstract void additionalUpdate(Map<String, Object> environmentData);
    
    // 我们不再调用被装饰对象的protected方法
    @Override
    protected void adjustWorkingParameters(Map<String, Object> environmentData) {
        // 装饰器自身的参数调整逻辑
    }
} 